package com.lsmo.android.util;

import java.util.List;
import java.util.Vector;

public class ResultSet {
	private ResultSetMetaData metaData;
	private int currentRowIndex = -1;
	private List<Object[]> rows = new Vector<Object[]>();

	public ResultSet(ResultSetMetaData metaData) {
		this.metaData = metaData;
	}

	void addRow(Object[] row) {
		rows.add(row);
	}

	int getRowCount() {
		return rows.size();
	}

	public boolean next() {
		currentRowIndex++;
		return currentRowIndex <= rows.size();
	}

	public String getString(int columnIndex) {
		return (String) ((Object[]) rows.get(currentRowIndex))[columnIndex];
	}

	public String getStringByName(String columnName) {
		return (String) ((Object[]) rows.get(currentRowIndex))[metaData
				.getColumenIndex(columnName)];
	}

	public ResultSetMetaData getMetaData() {
		return metaData;
	}
}